home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / programming / other / wild / developer / examples / src / ppctimagemapping / ppctimagemapping.c < prev    next >
C/C++ Source or Header  |  1999-01-25  |  2KB  |  82 lines

  1.  
  2. #include <exec/types.h>
  3. #include <startup.h>
  4. #include <inline/wild.h>
  5. #include <inline/ppct.h>
  6. #include <inline/exec.h>
  7. #include <inline/dos.h>
  8. #include <wild/wild.h>
  9. #include <wild/display_typeb2.h>
  10. #include <extensions/ppct.h>
  11.  
  12. struct WildExtension *PPctExtensionBase=NULL;
  13.  
  14. struct WildApp *WApp=NULL;
  15. UBYTE *Chunky=NULL;
  16.  
  17. void mousewait()
  18. {
  19.  UBYTE *mouse=0xbfe001;
  20.  while (mouse[0] & 64);
  21. }
  22.  
  23. void ShowImage()
  24. {
  25.  UWORD x,y;
  26.  ULONG pa=0,pb=0;
  27.  InitFrame(WApp);
  28.  for (y=0;y<256;y++)
  29.   {
  30.    for (x=0;x<256;x++)
  31.     {
  32.      WApp->wap_FrameBuffer->fb_Chunky[pa]=Chunky[pb];pa++;pb++;
  33.     }
  34.    pa+=64;    //hakkful, used only because i know the width of the view and i'm too lazy 
  35.            // to code something better...
  36.   }
  37.  DisplayFrame(WApp);     
  38. }
  39.  
  40. int main()
  41. {
  42.  if (PPctExtensionBase=LoadExtension("PPct.library",1))
  43.   {
  44.    ULONG args[2];
  45.    if (ReadArgs("IMAGE/A,PALETTE/A",&args,0))
  46.     {
  47.      ULONG *Palette,*Image;
  48.      if (Image=LoadFile(0,args[0],0))
  49.       {
  50.        if (Palette=LoadFile(0,args[1],0))
  51.         {
  52.          ULONG *ppct;
  53.          ppct=MakePPCTTags(    PPCT_ChunkyArray,Palette,PPCT_MaxTreeDepth,10,
  54.                       PPCT_ChunkyPixelsNum,256,PPCT_RGBMode,TRUE,
  55.                      PPCT_MaxColorsPerNode,1,0,0);
  56.          Chunky=AllocVec(262144,0);
  57.          ImagePPCT(ppct,Image,Chunky,262144);
  58.           {  
  59.            ULONG *msg;
  60.            msg=CreateMsgPort();
  61.            if (WApp=AddWildAppTags(msg,    WIAP_Name,"PPCT Image Mapping!",WIAP_BaseName,"PPctMap",
  62.                            WIAP_PrefsHandle,TRUE,WIAP_DisplayModule,"TryPeJam+",
  63.                            WIAP_TypeABCD,0x00020000,WIAP_TypeEFGH,0x00000000,
  64.                            WIDI_Width,320,WIDI_Height,256,WIDI_Depth,8,
  65.                            WIDI_Palette,Palette,0,0))
  66.             {
  67.              ShowImage();     
  68.              mousewait(); 
  69.              RemWildApp(WApp);
  70.             }
  71.            DeleteMsgPort(msg);
  72.           }
  73.          FreePPCT(ppct);
  74.          FreeVec(Chunky);
  75.          FreeVecPooled(Palette);
  76.         }
  77.        FreeVecPooled(Image);
  78.       }
  79.     }
  80.    KillExtension(PPctExtensionBase); 
  81.   }  
  82. }